﻿# CMakeList.txt: Modules 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.31)

set(CXX_STANDARD 23)
set(CXX_STANDARD_REQUIRED YES)
#set(CXX_EXTENSIONS OFF)

if(MSVC)
	add_compile_options(/experimental:module)
	add_compile_options(/std::c++latest)
	set_source_files_properties(
		module1/singleton.ixx
		moduel2/myClass.ixx
		PROPERTIES
		VS_TOOL_OVERRIDE
		"CXX"
	)
endif()


# 如果支持，请为 MSVC 编译器启用热重载。
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("Modules")

# 将源代码添加到此项目的可执行文件。
add_executable (Modules "Modules.cpp" "Modules.h" "module1/singleton.ixx" "module2/myClass.ixx" "module2/myClass.cpp")

target_include_directories(
	Modules
		PRIVATE
		${CMAKE_SOURCE_DIR}/module1
		${CMAKE_SOURCE_DIR}/module2
)

target_sources(
	Modules
		PUBLIC
		FILE_SET CXX_MODULES
		FILES
		"module1/singleton.ixx"
		"module2/myClass.ixx"
)

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET Modules PROPERTY CXX_STANDARD 20)
endif()

# TODO: 如有需要，请添加测试并安装目标。
